There is a known "xm console" issue related with VMX. When "serial" is
authorjrb44@plym.cl.cam.ac.uk <jrb44@plym.cl.cam.ac.uk>
Thu, 2 Feb 2006 18:15:22 +0000 (19:15 +0100)
committerjrb44@plym.cl.cam.ac.uk <jrb44@plym.cl.cam.ac.uk>
Thu, 2 Feb 2006 18:15:22 +0000 (19:15 +0100)
enabled in script and no once uses "xm console" to read the console,
VMX boting will hang due to the buffer is full.
I added a "select" before "write". If it could not be written,
unix_write will Return immediately and it will not block the VMX
booting. With this fix, we can  make VMX's serial enable by default.

Signed-off-by: Yu Ping <ping.y.yu@intel.com>
Modified to patch xmexample.hvm. Put through xenrt on a VMX box.

Signed-off-by: James Bulpin <james@xensource.com>
tools/examples/xmexample.hvm
tools/ioemu/vl.c

index a1b893b0d5ebbed7220f64d059d1d1f4869220a8..5cdf03dc832e072e1542d89b630970b4481f2c2a 100644 (file)
@@ -130,7 +130,7 @@ vncviewer=1
 #-----------------------------------------------------------------------------
 #   serial port re-direct to pty deivce, /dev/pts/n 
 #   then xm console or minicom can connect
-#serial='pty'
+serial='pty'
 
 #----------------------------------------------------------------------------
 # enable ne2000, default = 0(use pcnet)
index aeed28e1e2514537fbee06f4b6dd20453f5261c0..618ddc0a3171adf4353d805df5fdeb06c8c286f1 100644 (file)
@@ -957,19 +957,34 @@ static CharDriverState *stdio_clients[STDIO_MAX_CLIENTS];
 
 static int unix_write(int fd, const uint8_t *buf, int len1)
 {
-    int ret, len;
+    int ret,sel_ret,len;
+    int max_fd;
+    fd_set writefds;
+    struct timeval timeout;
+
+    max_fd = fd;  
 
     len = len1;
     while (len > 0) {
-        ret = write(fd, buf, len);
-        if (ret < 0) {
-            if (errno != EINTR && errno != EAGAIN)
-                return -1;
-        } else if (ret == 0) {
-            break;
-        } else {
-            buf += ret;
-            len -= ret;
+        FD_ZERO(&writefds);
+        FD_SET(fd, &writefds);
+       timeout.tv_sec = 0;
+       timeout.tv_usec = 0;
+       sel_ret = select(max_fd + 1, NULL, &writefds, 0, &timeout);
+       if (sel_ret <= 0) {
+               /* Timeout or select error */
+            return -1;
+       } else {
+            ret = write(fd, buf, len);
+            if (ret < 0) {
+                if (errno != EINTR && errno != EAGAIN)
+                    return -1;
+            } else if (ret == 0) {
+                   break;
+            } else {
+                   buf += ret;
+                    len -= ret;
+            }
         }
     }
     return len1 - len;